package com.liu.my_blog_system.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liu.my_blog_system.mapper.TbFriendLinkMapper;
import com.liu.my_blog_system.entity.TbFriendLink;
import com.liu.my_blog_system.service.TbFriendLinkService;
import com.liu.my_blog_system.utils.Result;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * (TbFriendLink)表服务实现类
 * @author liuchengjie
 * @since 2021-04-20 11:24:12
 */
@Service
@Transactional
public class TbFriendLinkServiceImpl extends ServiceImpl<TbFriendLinkMapper, TbFriendLink> implements TbFriendLinkService {

    /**
     * 分页查询友情链接
     * @param current
     * @param size
     * @return
     */
    @Override
    public Result findFriendLinkPage(Long current, Long size) {
        Page<TbFriendLink> friendLinkPage = new Page<>(current, size);
        Page<TbFriendLink> linkPage = baseMapper.selectPage(friendLinkPage, null);
        List<TbFriendLink> records = linkPage.getRecords();
        long total = linkPage.getTotal();
        return Result.ok().data("total",total).data("records",records);
    }
}
